<?php echo $this->headScript();?>
<?php echo $this->headLink();?>
<?php echo $this->partial('resume/menu-add-resume.phtml', array('step' => 'experience', 'resumeId' => $this->resumeId));?>
<div class="from-add-01" id="exp_nomal">
    <form name="frm" method="post" action="/resume/save-experience" onsubmit="return checkValid()">
	<h2>Experience</h2>
	<ul>
        <li>
            <label>&nbsp;</label>
            <input type="checkbox" name="show" class="showother" value=""> Other
        </li>
		<li>
			<label></label>
			<em class="error"></em>
		</li>
		<li>
			<label>Start date</label>
			<input type="text" name="startdate" id="startdate" value="<?php echo $this->experienceRowSet->getStartDate();?>" style="width:120px">
			<b>&nbsp;&nbsp;End date</b>
			<input type="text" name="enddate" id="enddate" value="<?php echo $this->experienceRowSet->getEndDate();?>" style="width:120px">
		</li>
		<li>
			<label>Job Title <em>*</em></label>
			<input type="text" style="width:390px" name="job_title" id="job_title" value="<?php echo $this->experienceRowSet->getJobTitle();?>"/>
		</li>
		<li>
			<label>Company <em>*</em></label>
			<input type="text" style="width:390px" name="company_name" id="company_name" value="<?php echo $this->experienceRowSet->getCompanyName();?>"/>
		</li>
		<li>
            <label>Function</label>
            <input type="text" name="function" class="function" value="" style="width:390px"/>
			<div class="multiselect" style="width:800px; height:250px; padding:10px;display:none; position:absolute;margin-left:170px">
				<div style="width: 33%; float: left">
					<ul style="list-style-type:none;">
					<?php 
					$i = 1;
					$checked = '';
					foreach($this->listFunction as $function) :
						if($i % 23 == 0): echo '</ul></div><div style="width: 33%; float: left"><ul style="list-style-type:none;">';endif;
						if($function['parent_function_id'] == 0) echo '<div><strong>'. $function['name'] .'</strong></div>';
						if(in_array($function['function_id'], $this->experFunction, true)) $checked = "checked";
						else $checked = '';
					?>
						<?php if($function['parent_function_id'] != 0):?>
						<li style="float:none;display:block;"><input type="checkbox" name="option[]" value="<?php echo $function['function_id']?>" <?php echo $checked;?>/> <?php echo $function['name']?></li>
						<?php endif;?>	
					<?php 
					$i++;
					endforeach;?>
					</ul>
				</div>
				<div style="clear: both">&nbsp;</div>
			</div>
		</li>
		<li>
			<label>Duties</label>
			<textarea name="duties" id="duties"><?php echo $this->experienceRowSet->getDuties();?></textarea>
		</li>
		<li>
			<label>&nbsp;</label>
			<div class="actions">
				<input type="hidden" name="resume_id" value="<?php echo $this->resumeId; ?>" />
				<input type="hidden" name="experid" value="<?php echo $this->experienceRowSet->getId();?>" />
				<a href="/resume/education/id/<?php echo $this->resumeId; ?>" style="text-decoration:none;">
					<input type="button" class="button02" name="button" value="Back"/>
				</a>
				<input type="submit" class="button01" name="button" value="Save"/>
				<input type="submit" class="button01" name="button" value="Next"/>
			</div>
		</li>
	</ul>
</form>
</div>
<div class="from-add-01" id="exp_other" style="display:none">
    <form name="frm" method="post" action="/resume/save-experience1" onsubmit="return checkValid2()">
    <h2>Experience</h2>
    <ul>
        <li>
            <input type="checkbox" name="show1" class="showother" checked="checked"> Other
        </li>
        <li>
            <em class="error"></em>
        </li>
        <li>
			<textarea name="experience_other" id="experience_other" style="height:300px; width:570px"><?php echo @$this->experienceRowSet->getExperienceOther(); ?></textarea>
        </li>
        <li>
            <div class="actions">
                <input type="hidden" name="resume_id" value="<?php echo $this->resumeId; ?>" />
                <input type="hidden" name="experid" value="<?php echo $this->experienceRowSet->getId();?>" />
                <a href="/resume/education/id/<?php echo $this->resumeId; ?>" style="text-decoration:none;">
                    <input type="button" class="button02" name="button" value="Back"/>
                </a>
                <input type="submit" class="button01" name="button" value="Save"/>
                <input type="submit" class="button01" name="button" value="Next"/>
            </div>
        </li>
    </ul>
    </form>
</div>
<div class="summary">
	<h2>Career Summary</h2>
	<ul>
	 <?php foreach($this->rows as $row) : 
		//$date = date_create($row->getStartDate());
		//$startDate = date_format($date, 'M Y');
		
		//$date = date_create($row->getEndDate());
		//$endDate = date_format($date, 'M Y');
	?>
		<li>
			<div class="edit" style="clear:both">
				<p><?php echo $row->getStartDate();?><?php echo ($row->getEndDate())? ' - ' . $row->getEndDate():'Experience Other'; ?></p>
				<p class="action-link">
					<a href="/resume/experience/id/<?php echo $this->resumeId; ?>/experid/<?php echo $row->getId();?>">Edit</a> | 
					<a href="/resume/del-experience/id/<?php echo $this->resumeId; ?>/experid/<?php echo $row->getId();?>">Delete</a>
				</p>
			</div>
			<div class="jobs">
                <?php if($row->getExperienceOther()) :?>
                    <p>Experience Other</p>
                <?php else:?>
    				<p class="name" style="font-weight:bold;text-transform: uppercase;"><a href="#"><?php echo $row->getCompanyName();?></a></p>
    				<p><?php echo $row->getJobTitle();?></p>
                <?php endif;?>
			</div>
		</li>
    <?php endforeach;?>
	</ul>
</div>

<script>
function checkValid()
{
	//var startdate = $("#startdate").val();
	//var enddate = $("#enddate").val();
	var job_title = $("#job_title").val();
	var company_name = $("#company_name").val();
    
    if(job_title == '' || company_name == '') {
        $('.error').html('Please input into field required (*)');
        return false;
    }
    return true;
}   

function checkValid2()
{
    var other = $("#experience_other").val();
    
    if(other == '') {
        $('.error').html('Please input into field required (*)');
        return false;
    }
    return true;
}   
</script>

<script>
$(document).ready(function(){
    $('.showother').click(function(){
        if($(this).is(':checked')) {
        	$('input[name=show1]').attr('checked', true);
            $("#exp_nomal").hide('slow');
            $("#exp_other").show('slow');
        } else {
        	$('input[name=show]').attr('checked', false);
        	$("#exp_other").hide('slow');
            $("#exp_nomal").show('slow');
        }
    });
});

$(document).ready(function(){
    $(".function").click(function(){
        if(($(".multiselect").css('display')) == 'none') $(".multiselect").show('slow');
    });
});

$("body").click(function(e){
	var $parentClass = $(e.target).parents('.multiselect');
    if(e.target.className !== "function" && $parentClass.length < 1) {
    	$(".multiselect").hide('slow');
    	
    }       
});

//auto show lable check list in multiselect
var str = '';
$(':checkbox[name^=option]').each(function(){
	if($(this).attr('checked')){
		str = str + $(this).parent().text() + ';';
	} 
});
str = str.slice(0, -1)
$('.function').val(str);

//click chekcbox in mutiselect
$('.multiselect').bind('click', function() {
	var str = '';
	$(':checkbox[name^=option]').each(function(){
		if($(this).attr('checked')){
			str = str + $(this).parent().text() + ';';
		} 
	});
	str = str.slice(0, -1)
	$('.function').val(str);
});
	
jQuery.fn.multiselect = function() {
    $(this).each(function() {
        var checkboxes = $(this).find("input:checkbox");
        checkboxes.each(function() {
            var checkbox = $(this);
           
        });
    });
};

$(".multiselect").multiselect();
</script>